Functions and Lazy Evaluation in Prolog
نویسندگان
چکیده
There are several proposals for extending Prolog with functional capabilities. The basic idea is to enlarge the language with function definitions that are translated (or expanded) into Prolog predicates, analogously to what is done for Definite Clause Grammars (DCG’s). It is easy to perform such a translation for a basic functional extension, but it requires an additional effort to incorporate more sophisticated functional capabilities such as higher order, lambda abstractions and lazy evaluation. In this paper we describe an extension that covers all these features. The main novelty is our treatment of laziness, as it is (optionally) associated to data type constructors instead of functions. We have found this approach very flexible, easy to use and efficient.
منابع مشابه
A Technique for Doing Lazy Evaluation in Logic
D We develop a natural technique for defining functions in logic, i.e. PROLOG, which directly yields lazy evaluation. Its use does not require any change to the PROLOG interpreter. Function definitions run as PROLOG programs and so run very efficiently. It is possible to combine lazy evaluation with nondeterminism and simulate coroutining. It is also possible to handle infinite data structures ...
متن کاملAdding equations to NU-Prolog
This paper describes an extension to NU-Prolog which allows evaluable functions to be deened using equations. We consider it to be the most pragmatic way of combining functional and relational programming. The implementation consists of several hundred lines of Prolog code and the underlying Prolog implementation was not modiied at all. However, the system is reasonably eecient and supports cor...
متن کاملA Declarative Debugging Scheme
We present a very simple but flexible declarative debugging scheme. A Abstract-1 declarative debugger can be defined in Prolog with a single clause, and relies on the definition of just two additional predicates. With suitable definitions of these predicates, the debugger can diagnose several classes of bugs in many languages. We give examples of diagnoses of wrong answers in functional, relati...
متن کاملFunctional Notation and Lazy Evaluation in Ciao
Certain aspects of functional programming provide syntactic convenience, such as having a designated implicit output argument, which allows function call nesting and sometimes results in more compact code. Functional programming also sometimes allows a more direct encoding of lazy evaluation, with its ability to deal with infinite data structures. We present a syntactic functional extension of ...
متن کاملEfficient Compilation of Lazy Narrowing into Prolog
The paper presents new techniques for the transformation of lazy narrowing in logic programs. A formalism, called demand patterns, is introduced , and used to deene a demand driven strategy to compute lazy narrowing. The strategy is used to produce standard PROLOG code from programs written in a functional-logic language. Our method has a number of advantages over other approaches. While it can...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Electr. Notes Theor. Comput. Sci.
دوره 206 شماره
صفحات -
تاریخ انتشار 2008